<?php
use \yii\helpers\Url;
use yii\helpers\Html;
// $this->registerJsFile(Url::to('@web/jselect/js/1507110761.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//ZurmoDialog.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//mobile-interactions.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js/jquery-1.11.2.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//jquery.bgiframe.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//ui.datepicker.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//common.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//newSurvey.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//afterLoading.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//sketch.js?version=2.0' , true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//jquery.plugin.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//jquery.countdown.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//support.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//jquery.fancybox.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//phone-element.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
// $this->registerJsFile(Url::to('@web/jselect/js//email-element.js?t=' . time(), true), ['position' => \yii\web\View::POS_END]);
use app\components\Log;
$signPackage = \app\components\Jssdk::getSignPackage();
?>
<?=Html::jsFile('https://res.wx.qq.com/open/js/jweixin-1.2.0.js')?>  
<iframe id="selfPage" name="selfPage" style="display: none;"></iframe>


<div class="formmain" style="display: none;"><form   target="selfPage" id="formPreview" class="survey_form newform" action="https://proxcrm.xgate.com/app/index.php/webforms/form/form?encid=b004a460-3ad7-75f1-7bd2-1fbadbb9cac6&tracker=350e92b9-5986-4f05-f72c-77289fac5343" method="post">
<div class="formInfo">
<div class="txt-form-title">Free exchange of experience loaded</div>
<div class="txt-form-desc">Completed and successfully<sup>&reg;</sup> submitted on or before x May 2016, the following information can be exchanged free Trial Pack.</div>
</div>
<div id="itemOnPage1" class="form-group col-sm-12 col-xs-12 nopad lname" style="display: block;"><input type="hidden" name="orders" value="1" /> <input type="hidden" id="emptyCheckErrorMessage1" name="emptyCheckErrorMessage1" value="" /> <input type="hidden" id="uniqueCheckErrorMessage1" name="uniqueCheckErrorMessage_1" value="" /> <input type="hidden" id="validCheckErrorMessage1" name="validCheckErrorMessage_1" value="" /> <input type="hidden" name="HiddenFieldID1" value="423" />
<ul>
<li id="foli1" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field1" id="title1" class="frmquestion cstm_frmquestion desc"> last_name </label>
<div class="frmanswer cstm_frmanswer"><input placeholder="last_name" type="text" value="" class="medium field text typtxt col-sm-6 col-xs-12" name="Field1_1" id="Field1-1" /></div>
<p id="Type1" style="display: none; clear: both;"><input type="hidden" name="fieldtype_1" id="fieldtype_1" value="lastname" /></p>
<p id="ErrMsg1" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div id="itemOnPage2" class="form-group col-sm-12 col-xs-12 nopad" style="display: block;"><input type="hidden" name="orders" value="2" /> <input type="hidden" id="emptyCheckErrorMessage2" name="emptyCheckErrorMessage2" value="" /> <input type="hidden" id="uniqueCheckErrorMessage2" name="uniqueCheckErrorMessage_2" value="" /> <input type="hidden" id="validCheckErrorMessage2" name="validCheckErrorMessage_2" value="Please fill valid information" /> <input type="hidden" name="length_2" id="length_2" value="0" /> <input type="hidden" name="HiddenFieldID2" value="424" />
<ul>
<li id="foli2" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field2" id="title2" class="frmquestion cstm_frmquestion desc"> mobile </label>
<div class="frmanswer cstm_frmanswer iselect">
<div class="col-sm-12 col-xs-12 nopad"><input placeholder="mobile" type="tel" class="field text medium typtxt col-sm-6 col-xs-12 mobile" style="width: 100%;" name="Field2" id="Field2" data-target="Field2" /></div>
</div>
<p id="Type2" style="display: none; clear: both;"><input type="hidden" name="uniqueCheck_2" id="uniqueCheck_2" value="0" /> <input type="hidden" name="fieldtype_2" id="fieldtype_2" value="phone" /></p>
<p id="ErrMsg2" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div id="itemOnPage3" class="form-group col-sm-12 col-xs-12 nopad" style="display: block;"><input type="hidden" name="orders" value="3" /> <input type="hidden" id="emptyCheckErrorMessage3" name="emptyCheckErrorMessage3" value="" /> <input type="hidden" id="uniqueCheckErrorMessage3" name="uniqueCheckErrorMessage_3" value="" /> <input type="hidden" id="validCheckErrorMessage3" name="validCheckErrorMessage_3" value="Please fill valid information" /> <input type="hidden" name="HiddenFieldID3" value="425" />
<ul>
<li id="foli3" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field3" id="title3" class="frmquestion cstm_frmquestion desc"> email </label>
<div class="frmanswer cstm_frmanswer iselect">
<div class="col-sm-12 col-xs-12 nopad"><input placeholder="email" type="text" class="field text medium typtxt col-sm-6 col-xs-12 " name="Field3" id="Field3" data-target="Field3" /></div>
</div>
<p id="Type3" style="display: none; clear: both;"><input type="hidden" name="uniqueCheck_3" id="uniqueCheck_3" value="0" /> <input type="hidden" name="fieldtype_3" id="fieldtype_3" value="email" /></p>
<p id="ErrMsg3" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div id="itemOnPage4" class="form-group col-sm-12 col-xs-12 nopad" style="display: none;"><input type="hidden" name="orders" value="4" /> <input type="hidden" id="emptyCheckErrorMessage4" name="emptyCheckErrorMessage4" value="" /> <input type="hidden" id="uniqueCheckErrorMessage4" name="uniqueCheckErrorMessage_4" value="" /> <input type="hidden" id="validCheckErrorMessage4" name="validCheckErrorMessage_4" value="" /> <input type="hidden" name="HiddenFieldID4" value="426" />
<ul>
<li id="foli4" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field4" id="title4" class="frmquestion cstm_frmquestion desc"> gender </label>
<div class="frmanswer cstm_frmanswer"><input placeholder="gender" type="hidden" value="" class="field text medium typtxt col-sm-6 col-xs-12" name="Field4" id="Field4" /></div>
<p id="Type4" style="display: none; clear: both;"><input type="hidden" name="fieldtype_4" id="fieldtype_4" value="hiddentext" /></p>
<p id="ErrMsg4" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div id="itemOnPage5" class="form-group col-sm-12 col-xs-12 nopad" style="display: none;"><input type="hidden" name="orders" value="5" /> <input type="hidden" id="emptyCheckErrorMessage5" name="emptyCheckErrorMessage5" value="" /> <input type="hidden" id="uniqueCheckErrorMessage5" name="uniqueCheckErrorMessage_5" value="" /> <input type="hidden" id="validCheckErrorMessage5" name="validCheckErrorMessage_5" value="" /> <input type="hidden" name="HiddenFieldID5" value="427" />
<ul>
<li id="foli5" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field5" id="title5" class="frmquestion cstm_frmquestion desc"> openid </label>
<div class="frmanswer cstm_frmanswer"><input placeholder="openid" type="hidden" value="" class="field text medium typtxt col-sm-6 col-xs-12" name="Field5" id="Field5" /></div>
<p id="Type5" style="display: none; clear: both;"><input type="hidden" name="fieldtype_5" id="fieldtype_5" value="hiddentext" /></p>
<p id="ErrMsg5" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div id="itemOnPage6" class="form-group col-sm-12 col-xs-12 nopad" style="display: none;"><input type="hidden" name="orders" value="6" /> <input type="hidden" id="emptyCheckErrorMessage6" name="emptyCheckErrorMessage6" value="" /> <input type="hidden" id="uniqueCheckErrorMessage6" name="uniqueCheckErrorMessage_6" value="" /> <input type="hidden" id="validCheckErrorMessage6" name="validCheckErrorMessage_6" value="" /> <input type="hidden" name="HiddenFieldID6" value="471" />
<ul>
<li id="foli6" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field6" id="title6" class="frmquestion cstm_frmquestion desc"> wechat_code </label>
<div class="frmanswer cstm_frmanswer"><input placeholder="wechat_code" type="hidden" value="" class="field text medium typtxt col-sm-6 col-xs-12" name="Field6" id="Field6" /></div>
<p id="Type6" style="display: none; clear: both;"><input type="hidden" name="fieldtype_6" id="fieldtype_6" value="hiddentext" /></p>
<p id="ErrMsg6" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div id="itemOnPage7" class="form-group col-sm-12 col-xs-12 nopad" style="display: none;"><input type="hidden" name="orders" value="7" /> <input type="hidden" id="emptyCheckErrorMessage7" name="emptyCheckErrorMessage7" value="" /> <input type="hidden" id="uniqueCheckErrorMessage7" name="uniqueCheckErrorMessage_7" value="" /> <input type="hidden" id="validCheckErrorMessage7" name="validCheckErrorMessage_7" value="" /> <input type="hidden" name="HiddenFieldID7" value="428" />
<ul>
<li id="foli7" class=" col-sm-12 col-xs-12 nopad " style="top: 0px; left: 0px;"><label for="Field7" id="title7" class="frmquestion cstm_frmquestion desc"> card_number </label>
<div class="frmanswer cstm_frmanswer"><input placeholder="card_number" type="hidden" value="{##issuecode_JTEST_01}" class="field text medium typtxt col-sm-6 col-xs-12" name="Field7" id="Field7" /></div>
<p id="Type7" style="display: none; clear: both;"><input type="hidden" name="fieldtype_7" id="fieldtype_7" value="hiddentext" /></p>
<p id="ErrMsg7" class="siderror" style="display: none; clear: both;">&nbsp;</p>
</li>
</ul>
</div>
<div class="FormButton">
<div class="scfSubmitButtonBorder">
<div id="submitFormBtn" class="shadow hvr-icon-push " onclick="clickSave()">Submit</div>
<input type="hidden" name="mode" id="mode" /> <input type="hidden" id="externalRequestToken" name="externalRequestToken" value="03a5a02f90475fd" /></div>
</div>
</form></div>
<div class="weui-flex-item weui-flex" style="flex-direction:column;padding-top:20px">
    <div class="center tcenter" style="width:80%">
        <img src="https://imgsrv1.mailer08.net/images/dGVuYW50Mjg3YWRtaW4_/WTJGdGNHRnBaMjVmTWpJPQ/jselectLogo.png" alt="">
    </div>
    <canvas id="loading" width="150" height="150" class="center" style="background:#fff;padding:40px 0 20px"></canvas>
    
    <div class="tcenter f16" style="font-family:Atilla">
        会员卡激活中,请耐心等候......
    </div>
</div>

<!-- <butten onclick="test()">赋值</butten> -->
<script type="text/javascript">
var signPackage = <?= json_encode($signPackage) ?>;
console.log(signPackage);
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
appId: signPackage.appId, // 必填，公众号的唯一标识
timestamp: signPackage.timestamp, // 必填，生成签名的时间戳
nonceStr: signPackage.nonceStr, // 必填，生成签名的随机串
signature: signPackage.signature,// 必填，签名，见附录1
jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'onMenuShareQZone',
            'startRecord',
            'stopRecord',
            'onVoiceRecordEnd',
            'playVoice',
            'pauseVoice',
            'stopVoice',
            'onVoicePlayEnd',
            'uploadVoice',
            'downloadVoice',
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'translateVoice',
            'getNetworkType',
            'openLocation',
            'getLocation',
            'hideOptionMenu',
            'showOptionMenu',
            'hideMenuItems',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'showAllNonBaseMenuItem',
            'closeWindow',
            'scanQRCode',
            'chooseWXPay',
            'openProductSpecificView',
            'addCard',
            'chooseCard',
            'openCard',
            ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});



function clickSave() {
	var theForm = document.getElementById("formPreview");	
    $('.salesforce-replace-data').each(function(){
		var replaced = $("body").html().replace(
				new RegExp($(this).attr('name'), "igm"), $(this).val());
		$("body").html(replaced);
	});
    document.getElementById("mode").value = "Submit";
    theForm.submit()
}
window.onload = function(){
    window.requestAnimationFrame = (function(){
		  return  window.requestAnimationFrame       ||
				  window.webkitRequestAnimationFrame ||
				  window.mozRequestAnimationFrame    ||
				  function( callback ){
					window.setTimeout(callback, 1000 / 60);
				  };
		})();
 
    var canvas = document.getElementById('loading'),  //获取canvas元素
        context = canvas.getContext('2d'),  //获取画图环境，指明为2d
        centerX = canvas.width/2,   //Canvas中心点x轴坐标
        centerY = canvas.height/2,  //Canvas中心点y轴坐标
        rad = Math.PI*2/100, //将360度分成100份，那么每一份就是rad度
        speed = 0.1; //加载的快慢就靠它了 
    var circleR = canvas.width/2-10;
    var lineWidth = 10; 
    var lineColor = "#2bb2e1";
    var lineinsetWidth = 2;
    var lineinsetColor = "#2bb2e1";
    var maxNumber = 96;
    var textFontSize = 20;
    var textFont = textFontSize+"px Atilla";
    var textColor = "#2bb2e1";
    //绘制5像素宽的运动外圈
    function blueCircle(n){
        context.save();
        context.strokeStyle = lineColor; //设置描边样式
        context.lineWidth = 10; //设置线宽
        context.lineCap = "round";
        context.beginPath(); //路径开始
        context.arc(centerX, centerY, circleR , -Math.PI/2, -Math.PI/2 +n*rad, false); //用于绘制圆弧context.arc(x坐标，y坐标，半径，起始角度，终止角度，顺时针/逆时针)
        context.stroke(); //绘制
        context.closePath(); //路径结束
        context.restore();
    }
    //绘制白色外圈
    function whiteCircle(){
        context.save();
        context.beginPath();
        context.lineWidth = 2; //设置线宽
        context.strokeStyle = lineinsetColor;
        context.arc(centerX, centerY, circleR-2*lineWidth , 0, Math.PI*2, false);
        context.stroke();
        context.closePath();
        context.restore();
    }  
    //百分比文字绘制
    function text(n){
        context.save(); //save和restore可以保证样式属性只运用于该段canvas元素
        context.fillStyle = textColor; //设置描边样式
        context.font = textFont; //设置字体大小和字体
        //绘制字体，并且指定位置
        context.fillText(n.toFixed(0)+"%", centerX-textFontSize/2*3/2, centerY+textFontSize/2);
        //context.stroke(); //执行绘制
        context.restore();
    } 
    //动画循环
    (function drawFrame(){
        var start = window.requestAnimationFrame(drawFrame);
        context.clearRect(0, 0, canvas.width, canvas.height);
        whiteCircle();
        text(speed);
        blueCircle(speed);
        if(speed >= maxNumber) {
            cancelAnimationFrame(start)
        };
        speed += 0.1;
    }());

	var data = <?= $data ?>;
	$('#Field1-1').val(data.last_name)
	$('#Field2').val(data.mobile)
	$('#Field4').val(data.gender)
	$('#Field5').val(data.wechat_openid)
	$('#Field6').val(data.wechat_code)
	$("#submitFormBtn").click()
	// $('#Field3').val('308848022@qq.com')
	var count = 1 ;	
	var timer = setInterval(function(){
		if(count == 10) {
			clearInterval(timer);
			timer = null;
		}
		$.post("activation",data,function(re){
			console.log(re);
			if (re.status == "success") {
				wx.closeWindow();
				console.log(count)
				clearInterval(timer);
				timer = null;
			}
		},"json")

		count++
	},2000)
}


</script>	
